<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


use App\Http\Controllers\AuthController;
use App\Http\Controllers\CaseLibraryController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\SpeakerController;
use App\Http\Controllers\SystemController;
use App\Http\Controllers\UserCenterController;
use App\Http\Controllers\UserProjectController;
use Illuminate\Support\Facades\Route;

/**
 * JWT 用户鉴权基础路由.
 * laravel-box定义.
 */
Route::group(
    [
        'prefix' => 'auth',
        'middleware' => ['allow', 'refresh']
    ],
    function ($router) {
        $router->post('logout', [AuthController::class, 'logout']);
        $router->post('refresh', [AuthController::class, 'refresh']);
        $router->post('me', [AuthController::class, 'me']);
        $router->post('follow', [UserCenterController::class, 'followList']); // 我的关注列表
        // 个人中心-邀约申请列表
        $router->get('invitation/list', [UserCenterController::class, 'invitationList']);
        // 个人中心-邀约申请-撤销原因
        $router->get('invitation/revoke', [UserCenterController::class, 'invitationRevoke']);
    }
);

Route::group(
    [
        'prefix' => 'auth',
        'middleware' => ['allow', 'throttle:20,1'], // 允许跨域->middleware(['allow', 'throttle:20,1'])
    ],
    function ($router) {
        $router->post('login', [AuthController::class, 'login']);
        $router->post('register', [AuthController::class, 'register']);
        $router->post('forget', [AuthController::class, 'forgetPassword']); // 忘记密码
        $router->post('sms', [AuthController::class, 'sendCode']); // 发送验证码
        $router->any('wechat/scan', [AuthController::class, 'scanCode']); //微信扫码登录 T
        $router->any('wechat/bind', [AuthController::class, 'bindPhone']); //微信扫码登录绑定手机号 T
    }
);


Route::group(
    [
        'middleware' => ['allow'], // 允许跨域 、 刷新中间件
        'prefix' => 'speaker',
    ],
    function ($router) {
        // 外讲列表
        $router->post('list', [SpeakerController::class, 'speakerList']);
        // 外讲列表-无分页
        $router->post('lists', [SpeakerController::class, 'speakerLists']);
        // 外讲详情
        $router->post('detail', [SpeakerController::class, 'guestSpeakerDetail']);

        // 外籍讲者集合列表
        $router->post('collection/list', [SpeakerController::class, 'speakerCollectionList']);
        // 生成ppt
        $router->post('collection/ppt', [UserCenterController::class, 'ppt']);

        //创建或修改外籍讲者集合
        $router->post('guest/collection', [SpeakerController::class, 'createOrUpdateCollection']);
        // 提交讲者id到集合中
        $router->post('put/speakers', [SpeakerController::class, 'putIdToCollection']);
        // 获取合集分类列表
        $router->get('collection/cate', [SpeakerController::class, 'collectionList']);
        // 集合详情
        $router->post('collection/detail', [SpeakerController::class, 'collectionDetailList']);
        // 删除合集内讲者
        $router->post('detail/delete', [SpeakerController::class, 'deleteCollectionSpeaker']);

        // 分享合集
        $router->post('share/collection', [SpeakerController::class, 'shareCollection']);
        // 判断是否第一次创建合集或者长时间没有登录
        $router->get('collection/isFirst', [SpeakerController::class, 'isFirstForTime'])->middleware(['refresh']);
        // 删除集合
        $router->post('collection/delete', [SpeakerController::class, 'deleteCollection']);
        // 外讲推荐排序
        $router->post('recommend/speaker', [SpeakerController::class, 'recommendSpeaker']);



        // 复制合集
        $router->post('replicate/collection', [SpeakerController::class, 'replicateSpeakerCollection']);
    }

);
Route::group(
    [
        'prefix' => 'speaker',
    ],
    function ($router) {
        // 查看分享合集内的专家详情（不需要登录）
        $router->post('share/speakerDetail', [SpeakerController::class, 'guestSpeakerDetail2']);
        // 集合详情
        $router->post('share/collectDetail', [SpeakerController::class, 'collectionDetailList2']);
        // $router->get('url', [SpeakerController::class, 'urlRedirect']); // url 重定向
        // 20230620
        // 点赞
        $router->post('giveLike/speaker', [SpeakerController::class, 'giveLikeSpeaker']);
        // 取消点赞
        $router->post('cancelLike/speaker', [SpeakerController::class, 'CancelGiveLikeSpeaker']);
    }
);
Route::get('url', [SpeakerController::class, 'urlRedirect']);
Route::get('wechat/config', [SpeakerController::class, 'getWechatConfig']); // 获取微信js配置');
Route::any('wechat/scan', [AuthController::class, 'scanCode']); //微信扫码登录 T
Route::any('wechat/bind', [AuthController::class, 'bindPhone']); //微信扫码登录绑定手机号 T

Route::any('wechat/login', [AuthController::class, 'mobileLogin']); //移动端网页授权登录
// 广告
Route::get('ad', [HomeController::class, 'ad'])->middleware(['allow', 'throttle:20,1']);
// 留言
Route::post('message', [HomeController::class, 'leaveMessage']);

// 关于我们
Route::get('about', [SystemController::class, 'aboutUs']); //->middleware(['allow', 'throttle:10,1']);
// 联系我们
Route::get('config', [SystemController::class, 'config']); //->middleware(['allow', 'throttle:10,1']);

// 首页-服务案例
Route::get('home/serviceCase', [SystemController::class, 'homeServiceCase']); //->middleware(['allow', 'throttle:10,1']);;

// 服务案例详情
Route::get('serviceCase/detail', [SystemController::class, 'serviceCaseDetail']); //->middleware(['allow', 'throttle:10,1']);;

// 案例库-项目案例列表
Route::get('case/library', [CaseLibraryController::class, 'caseLibrary']);

// 关注/取消关注   $router->post('follow', [SpeakerController::class, 'follow']); // 关注、取消关注
Route::post('speaker/follow', [SpeakerController::class, 'follow'])->middleware(['allow', 'refresh']);

// 需要登录
// 邀约申请
Route::post('invitation/apply', [HomeController::class, 'invitationApply'])->middleware(['allow', 'refresh']);
// 保存个人信息
Route::post('user/saveInfo', [UserCenterController::class, 'userCenterInfoUpdate'])->middleware(['allow', 'refresh']);
// 保存认证信息
Route::post('user/authInfo', [UserCenterController::class, 'userCenterAuthUpdate'])->middleware(['allow', 'refresh']);
// 检查验证码
Route::get('user/checkCode', [SystemController::class, 'checkCode'])->middleware(['allow', 'refresh']);
// 更换手机号码
Route::get('user/changePhone', [UserCenterController::class, 'changePhone'])->middleware(['allow', 'refresh']);
// 重置密码
Route::get('user/resetPassword', [UserCenterController::class, 'resetPassword'])->middleware(['allow', 'refresh']);

// 获取七牛云token
Route::get('getQiniuToken', [SystemController::class, 'getQiniuToken'])->middleware(['allow']);
// 客户说
Route::get('customer/said', [SystemController::class, 'customerSaid'])->middleware(['allow']);
// 客服管理
Route::get('customer/service', [SystemController::class, 'getCustomerService'])->middleware(['allow']);

// 删除被锁用户
Route::get('delete/lock', [SystemController::class, 'deleteLockUser'])->middleware(['allow']);
// 我的项目路由组
Route::group(
    [
        'prefix' => 'project',
        'middleware' => ['allow', 'refresh']
    ],
    function ($router) {
        // 个人中心-项目列表
        $router->post('list', [UserProjectController::class, 'projectList']);
        // 个人中心-项目列表-会议管理
        $router->get('meeting/list', [UserProjectController::class, 'projectMeetingList']);
        // 个人中心-项目列表-会议管理-讲者信息列表
        $router->get('meeting/speaker/list', [UserProjectController::class, 'projectMeetingSpeakerList']);
        // 个人中心-项目列表-会议管理-讲者信息列表-专家邀请阶段信息
        $router->get('meeting/speaker/invitation', [UserProjectController::class, 'projectMeetingSpeakerInvitation']);
        // 个人中心-项目列表-会议管理-讲者信息列表-专家沟通阶段信息
        $router->get('meeting/speaker/connect', [UserProjectController::class, 'projectMeetingSpeakerConnect']);
    }
);
